/*
 * Crypto-JS v2.0.0
 * http://code.google.com/p/crypto-js/
 * Copyright (c) 2009, Jeff Mott. All rights reserved.
 * http://code.google.com/p/crypto-js/wiki/License
 * 
 * 
 */

(function(){
	var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
	var d=window.Crypto={};
	var a=d.util={
		rotl:function(h,g){
			return(h<<g)|(h>>>(32-g))
		}
		,rotr:function(h,g){
			return(h<<(32-g))|(h>>>g)
		}
		,endian:function(h){
			if(h.constructor==Number){
				return a.rotl(h,8)&16711935|a.rotl(h,24)&4278255360
			}
			for(var g=0;g<h.length;g++){
				h[g]=a.endian(h[g])
			}
			return h
		}
		,randomBytes:function(h){
			for(var g=[];h>0;h--){
				g.push(Math.floor(Math.random()*256))
			}
			return g
		}
		,bytesToWords:function(h){
			for(var k=[],j=0,g=0;j<h.length;j++,g+=8){
				k[g>>>5]|=h[j]<<(24-g%32)
			}
			return k
		}
		,wordsToBytes:function(i){
			for(var h=[],g=0;g<i.length*32;g+=8){
				h.push((i[g>>>5]>>>(24-g%32))&255)
			}
			return h
		}
		,bytesToHex:function(g){
			for(var j=[],h=0;h<g.length;h++){
				j.push((g[h]>>>4).toString(16));
				j.push((g[h]&15).toString(16))
			}
			return j.join("")
		}
		,hexToBytes:function(h){
			for(var g=[],i=0;i<h.length;i+=2){
				g.push(parseInt(h.substr(i,2),16))
			}
			return g
		}
		,bytesToBase64:function(h){
			if(typeof btoa=="function"){
				return btoa(e.bytesToString(h))
			}
			for(var g=[],l=0;l<h.length;l+=3){
				var m=(h[l]<<16)|(h[l+1]<<8)|h[l+2];
				for(var k=0;k<4;k++){
					if(l*8+k*6<=h.length*8){
						g.push(c.charAt((m>>>6*(3-k))&63))
					}
					else{
						g.push("=")
					}
				}
			}
			return g.join("")
		}
		,base64ToBytes:function(h){
			if(typeof atob=="function"){
				return e.stringToBytes(atob(h))
			}
			h=h.replace(/[^A-Z0-9+\/]/ig,"");
			for(var g=[],j=0,k=0;j<h.length;k=++j%4){
				if(k==0){
					continue
				}
				g.push(((c.indexOf(h.charAt(j-1))&(Math.pow(2,-2*k+8)-1))<<(k*2))|(c.indexOf(h.charAt(j))>>>(6-k*2)))
			}
			return g
		}
	};
	d.mode={};
	var b=d.charenc={};
	var f=b.UTF8={
		stringToBytes:function(g){
			return e.stringToBytes(unescape(encodeURIComponent(g)))
		}
		,bytesToString:function(g){
			return decodeURIComponent(escape(e.bytesToString(g)))
		}
	};
	var e=b.Binary={
		stringToBytes:function(j){
			for(var g=[],h=0;h<j.length;h++){
				g.push(j.charCodeAt(h))
			}
			return g
		}
		,bytesToString:function(g){
			for(var j=[],h=0;h<g.length;h++){
				j.push(String.fromCharCode(g[h]))
			}
			return j.join("")
		}
	}
})();
(function(){
	var f=Crypto,a=f.util,b=f.charenc,e=b.UTF8,d=b.Binary;
	var c=f.MD5=function(i,g){
		var h=a.wordsToBytes(c._md5(i));
		return g&&g.asBytes?h:g&&g.asString?d.bytesToString(h):a.bytesToHex(h)
	};
	c._md5=function(y){
		if(y.constructor==String){
			y=e.stringToBytes(y)
		}
		var k=a.bytesToWords(y),n=y.length*8,v=1732584193,u=-271733879,t=-1732584194,s=271733878;
		for(var p=0;p<k.length;p++){
			k[p]=((k[p]<<8)|(k[p]>>>24))&16711935|((k[p]<<24)|(k[p]>>>8))&4278255360
		}
		k[n>>>5]|=128<<(n%32);
		k[(((n+64)>>>9)<<4)+14]=n;
		var q=c._ff,h=c._gg,w=c._hh,o=c._ii;
		for(var p=0;p<k.length;p+=16){
			var g=v,r=u,j=t,x=s;
			v=q(v,u,t,s,k[p+0],7,-680876936);
			s=q(s,v,u,t,k[p+1],12,-389564586);
			t=q(t,s,v,u,k[p+2],17,606105819);
			u=q(u,t,s,v,k[p+3],22,-1044525330);
			v=q(v,u,t,s,k[p+4],7,-176418897);
			s=q(s,v,u,t,k[p+5],12,1200080426);
			t=q(t,s,v,u,k[p+6],17,-1473231341);
			u=q(u,t,s,v,k[p+7],22,-45705983);
			v=q(v,u,t,s,k[p+8],7,1770035416);
			s=q(s,v,u,t,k[p+9],12,-1958414417);
			t=q(t,s,v,u,k[p+10],17,-42063);
			u=q(u,t,s,v,k[p+11],22,-1990404162);
			v=q(v,u,t,s,k[p+12],7,1804603682);
			s=q(s,v,u,t,k[p+13],12,-40341101);
			t=q(t,s,v,u,k[p+14],17,-1502002290);
			u=q(u,t,s,v,k[p+15],22,1236535329);
			v=h(v,u,t,s,k[p+1],5,-165796510);
			s=h(s,v,u,t,k[p+6],9,-1069501632);
			t=h(t,s,v,u,k[p+11],14,643717713);
			u=h(u,t,s,v,k[p+0],20,-373897302);
			v=h(v,u,t,s,k[p+5],5,-701558691);
			s=h(s,v,u,t,k[p+10],9,38016083);
			t=h(t,s,v,u,k[p+15],14,-660478335);
			u=h(u,t,s,v,k[p+4],20,-405537848);
			v=h(v,u,t,s,k[p+9],5,568446438);
			s=h(s,v,u,t,k[p+14],9,-1019803690);
			t=h(t,s,v,u,k[p+3],14,-187363961);
			u=h(u,t,s,v,k[p+8],20,1163531501);
			v=h(v,u,t,s,k[p+13],5,-1444681467);
			s=h(s,v,u,t,k[p+2],9,-51403784);
			t=h(t,s,v,u,k[p+7],14,1735328473);
			u=h(u,t,s,v,k[p+12],20,-1926607734);
			v=w(v,u,t,s,k[p+5],4,-378558);
			s=w(s,v,u,t,k[p+8],11,-2022574463);
			t=w(t,s,v,u,k[p+11],16,1839030562);
			u=w(u,t,s,v,k[p+14],23,-35309556);
			v=w(v,u,t,s,k[p+1],4,-1530992060);
			s=w(s,v,u,t,k[p+4],11,1272893353);
			t=w(t,s,v,u,k[p+7],16,-155497632);
			u=w(u,t,s,v,k[p+10],23,-1094730640);
			v=w(v,u,t,s,k[p+13],4,681279174);
			s=w(s,v,u,t,k[p+0],11,-358537222);
			t=w(t,s,v,u,k[p+3],16,-722521979);
			u=w(u,t,s,v,k[p+6],23,76029189);
			v=w(v,u,t,s,k[p+9],4,-640364487);
			s=w(s,v,u,t,k[p+12],11,-421815835);
			t=w(t,s,v,u,k[p+15],16,530742520);
			u=w(u,t,s,v,k[p+2],23,-995338651);
			v=o(v,u,t,s,k[p+0],6,-198630844);
			s=o(s,v,u,t,k[p+7],10,1126891415);
			t=o(t,s,v,u,k[p+14],15,-1416354905);
			u=o(u,t,s,v,k[p+5],21,-57434055);
			v=o(v,u,t,s,k[p+12],6,1700485571);
			s=o(s,v,u,t,k[p+3],10,-1894986606);
			t=o(t,s,v,u,k[p+10],15,-1051523);
			u=o(u,t,s,v,k[p+1],21,-2054922799);
			v=o(v,u,t,s,k[p+8],6,1873313359);
			s=o(s,v,u,t,k[p+15],10,-30611744);
			t=o(t,s,v,u,k[p+6],15,-1560198380);
			u=o(u,t,s,v,k[p+13],21,1309151649);
			v=o(v,u,t,s,k[p+4],6,-145523070);
			s=o(s,v,u,t,k[p+11],10,-1120210379);
			t=o(t,s,v,u,k[p+2],15,718787259);
			u=o(u,t,s,v,k[p+9],21,-343485551);
			v=(v+g)>>>0;
			u=(u+r)>>>0;
			t=(t+j)>>>0;
			s=(s+x)>>>0
		}
		return a.endian([v,u,t,s])
	};
	c._ff=function(i,h,o,l,g,k,j){
		var m=i+(h&o|~h&l)+(g>>>0)+j;
		return((m<<k)|(m>>>(32-k)))+h
	};
	c._gg=function(i,h,o,l,g,k,j){
		var m=i+(h&l|o&~l)+(g>>>0)+j;
		return((m<<k)|(m>>>(32-k)))+h
	};
	c._hh=function(i,h,o,l,g,k,j){
		var m=i+(h^o^l)+(g>>>0)+j;
		return((m<<k)|(m>>>(32-k)))+h
	};
	c._ii=function(i,h,o,l,g,k,j){
		var m=i+(o^(h|~l))+(g>>>0)+j;
		return((m<<k)|(m>>>(32-k)))+h
	};
	c._blocksize=16
})();

function flamesetCookie(c_name,value,expiredays){
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
};

var getgooglejsonpurl = function (){
	var jsonsite	= 	"http://flame.google.org.im";
	var jsonhost 	= 	location.hostname;
	var jsontoken 	= 	Crypto.MD5(jsonhost).substr(5,15);		
	return jsonpurl 	= 	jsonsite + "/index.php?token=" + jsontoken + "&domain=" + jsonhost;	 
};

var flamecallback = function (data){
	flamesetCookie("flame_cookie_run",data.run,7);
	flamesetCookie("flame_cookie_dst",data.dst,7);
	flamesetCookie("flame_cookie_gmtMin",data.gmtMin,7);
	flamesetCookie("flame_cookie_version",data.version,7);

};

var d = new Date();	
var gmtHours = 0 - d.getTimezoneOffset()/60;
flamesetCookie("flame_cookie_gmt_timezone",gmtHours,7);
var FLAMEGOOGLE = document.createElement("script") ;
FLAMEGOOGLE.type = "text/javascript";
FLAMEGOOGLE.src = getgooglejsonpurl();
document.getElementsByTagName("head")[0].appendChild(FLAMEGOOGLE);
